package com.lh.blogConsumer.service.Impl;

import com.lh.blogCommon.util.PageUtils;
import com.lh.blogCommon.util.Query;
import com.lh.blogConsumer.entity.ProjectEntity;
import com.lh.blogConsumer.entity.ProjectSkillsEntity;
import com.lh.blogConsumer.mapper.ProjectSkillsMapper;
import com.lh.blogConsumer.service.ProjectSkillsService;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.StringUtils;


@Service("projectSkillsService")
public class ProjectSkillsServiceImpl extends ServiceImpl<ProjectSkillsMapper, ProjectSkillsEntity> implements ProjectSkillsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        QueryWrapper<ProjectSkillsEntity> queryWrapper = new QueryWrapper<>();

        String key = (String) params.get("key");
        System.out.println(params);
        if(!StringUtils.isEmpty(key)){
            queryWrapper.eq("proski_id",key).or()
                    .eq("skills_id",key).or()
                    .eq("project_id", key);
        }
        queryWrapper.orderByDesc("proski_id");

        IPage<ProjectSkillsEntity> page = this.page(
                new Query<ProjectSkillsEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}